<extend name="Base/common"/>
<block name="head_css">
<link href="__PUBLIC__/Green/css/usercenter.css" rel='stylesheet' type='text/css' />
</block>
<block name="head_script">
    <script type="text/javascript" src="__PUBLIC__/Green/js/usercenter.js"></script>
</block>
<block name="body">
    <div class="width1000">
       <div class="top_tit">
            <a href="{:U('User/index')}">用户中心</a> &gt;&gt; 我的账号 &gt;&gt; <a href="{:U('User/secure')}">账户安全</a> &gt;&gt; 忘记密码
        </div>
        <div class="clearfix relative">
            <include file="User/nav" />
            <div class="user_center">
                <div class="user_profit">
                    <div class="profile_tit">
                       <eq name="type" value="cash">修改支付密码<else />修改登录密码</eq>
                    </div>
                    <div class="profile_person">

                        <form class="form-horizontal" id="changePhone" action="__SELF__">
                          <div class="form-group">
                            <label class="col-sm-2 control-label">已认证手机</label>
                            <div class="col-sm-10">
                                <p class="form-control-static">{$mobile}</p>
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="verfyCode" class="col-sm-2 control-label">手机校验码</label>
                            <div class="col-sm-6">
                                <input type="text" name="verfyCode" class="form-control" id="verfyCode" placeholder="验证码" disabled="disabled">
                            </div>
                            <div class="col-sm-4">
                                <button type="button" id="getVerfy" class="btn btn-default">获取短信校验码</button>
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="verfyCode" class="col-sm-2 control-label"><eq name="type" value="cash">新支付密码<else />新登录密码</eq></label>
                            <div class="col-sm-6">
                                <input type="password" name="newpass" class="form-control" id="newpass" placeholder="<eq name="type" value="cash">新支付密码<else />新登录密码</eq>">
                            </div>
                          </div>
                          <div class="form-group">
                            <label for="verfyCode" class="col-sm-2 control-label">密码确认</label>
                            <div class="col-sm-6">
                                <input type="password" name="repass" class="form-control" id="repass" placeholder="密码确认">
                            </div>
                          </div>
                          <input type="hidden" name="type" value="{$type}" />
                          <button type="submit" class="pass_btn">提交</button>
                        </form>
                    
                    </div>
                    <div class="empty_div">&nbsp;</div>
                </div>
            </div>
        </div>
    </div>
</block>    
<block name="script">
<script type="text/javascript" src="__PUBLIC__/Green/js/insurance.js"></script>
<script type="text/javascript">
    highlight_nav("{:U('User/secure')}");
    highlight_nav("javascript:void(0);");
    
    var wait_time = 60; //60秒内

    function wait_next(){
        if(wait_time<=0){
            $('#getVerfy').each(function(){
                $(this).attr("disabled", false).text('获取验证码');
            });
            wait_time = 60;
        }else{
            wait_time --;
            $('#getVerfy').each(function(){
                $(this).attr("disabled", true).text('还有' + wait_time + '秒');
            });
            setTimeout('wait_next()',1000);
        }
    }
    
    $('#getVerfy').on('click',function(){
        var form = $(this)[0].form,
            url = "{:U('User/getVerifyMsg')}";
            $.post(url,{mobile:'{$mobile}',forget:1},function(data){
                if(data.status){
                    $('#verfyCode').attr('disabled',false);
                    wait_next();
                } else {
                    alert(data.info);
                }
            },"json");
    });
    
    $('#changePhone').validate({
                rules:{
                    newpass:{
                        required:true
                    },
                    repass:{
                        equalTo:'#newpass'
                    },
                    verfyCode:{
                        required:true
                    }
                },
                messages:{
                    newpass:{
                        required:'请填写新的<eq name="type" value="cash">支付<else />登录</eq>密码'
                    },
                    repass:{
                        equalTo:'两次输入的密码不同'
                    },
                    verfyCode:{
                        required:'请输入验证码'
                    }
                },
                submitHandler:function(form){
                    var self = $(form);
                    $.post(self.attr("action"), self.serialize(), function(data){
                        if(data.status){
                            alert(data.info);
                            $(form)[0].reset();
                        } else {
                            alert(data.info);
                        }
                    }, "json");
                }    
        });
</script>
</block>
